package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.request.ProjectTravelRequest;
import com.nbsaas.boot.project.data.entity.Project;
import com.nbsaas.boot.project.data.entity.ProjectTravel;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;

/**
 * 出差请求对象转换成实体对象
 */

public class ProjectTravelEntityConvert implements Converter<ProjectTravel, ProjectTravelRequest> {

    @Override
    public ProjectTravel convert(ProjectTravelRequest source) {
        ProjectTravel result = new ProjectTravel();
        BeanDataUtils.copyProperties(source, result);
        if (source.getProject() != null) {
            Project project = new Project();
            project.setId(source.getProject());
            result.setProject(project);
        }
        return result;
    }
}

